package top.hundreds.oasys.bean.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum AnnouncementType {
    INFORM(0, "通知"),
    ANNOUNCEMENT(1, "公告");

    @JsonValue
    @EnumValue
    private final Integer value;

    private final String label;

    public static AnnouncementType formValue(Object o) {
        if (o != null) {
            AnnouncementType[] announcementTypes = values();
            for (AnnouncementType announcementType : announcementTypes) {
                if (announcementType.getValue().equals(o)) {
                    return announcementType;
                }
            }
        }
        return null;
    }

    public static AnnouncementType formLabel(Object o) {
        if (o != null) {
            AnnouncementType[] announcementTypes = values();
            for (AnnouncementType announcementType : announcementTypes) {
                if(announcementType.getLabel().equals(o)){
                    return announcementType;
                }
            }
        }
        return null;
    }
}
